package com.by.controller;

import com.by.common.bean.ResultBean;
import com.by.common.controller.BaseController;
import com.by.service.GoodsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(tags = "商品管理")
@RequestMapping("/api")
@CrossOrigin
public class GoodsController extends BaseController {
    @Autowired
    GoodsService goodsService;

    @ApiOperation("查询商品")
    @GetMapping("/goods")
    public ResultBean query(){
        return success("秒杀商品",goodsService.querySecKillGoods());
    }

    @ApiOperation("抢购商品")
    @PostMapping("/goods")
    public ResultBean qiang(@RequestParam(required = true) int id,int userId){
        int rs = goodsService.qiang(id,userId);
        return success("抢购结果",rs);
    }
}
